const express = require("express")
const router = express.Router()
const Carousel = require("../models/Carousel")

// 获取所有轮播图
router.get("/getList", async (req, res) => {
  try {
    const carousels = await Carousel.find().sort({ createdAt: -1 }) // 按创建时间倒序
    res.json(carousels)
  } catch (err) {
    res.status(500).json({ error: "获取失败" })
  }
})

module.exports = router
